<template>
    <van-nav-bar class="title_bar" :title="title" left-text="返回" left-arrow @click-left="onClickLeft" style="z-index: 999;"/>
</template>

<script>
import {
	NavBar,
} from 'vant';

export default {
  name: "title-bar",
  props: {
    title: String
  },


  methods: {
    onClickLeft() {
      const path = this.$route.path;
      this.$router.go(-1);
      this.$nextTick(() => {
        if (path == this.$route.path) {
          this.$router.push({name: 'home'});
        }
      })
    }
  },

  components: {
    [NavBar.name]: NavBar,
  }
}
</script>

<style lang="scss" scoped>
.title_bar{
    position: fixed;
    width: 100%;
    top: 0;
    background-color: $green;
    color: white;
}
</style>
